<template>
  <div v-if="isHide">
    <group>
      <form-preview :header-label="$t('第'+time+'次')" :body-items="list" :footer-buttons="buttons"></form-preview>
    </group>
  </div>
</template>

<script>
  import {Group,FormPreview } from 'vux'
  export default {
    components: {Group,FormPreview },
    props:['orderData'],
    data(){
      return{
          time:'',
        list:[],
        buttons:[],
        isHide:true
      }
    },
    mounted(){
      console.log(this.orderData)
      this.getOrder(this.orderData)
    },
    methods:{
      //获取子订单详情,并判断是否评价
      getOrder(coid){
        let data={
          order_type:2,
          user_type:1
        }
          this.Ajax('post','/Order/order/detail/coid/'+coid,data,(res)=>{
            if(res.status=='200'){
                this.isHide=false
            }else {
             this.time=res.data.time
              let nurseName={label:'护士名称',value:res.data.nurse_name}
              this.list.push(nurseName)
              this.buttons=[]
              if(res.data.orderCommentByUser!==null){
                let star={label:'总评（星数）',value:res.data.orderCommentByUser.star}
                let text={label:'评价',value:res.data.orderCommentByUser.text}
                this.list.push(star)
                this.list.push(text)
              }else{
                let nurse_eval={
                  style:'primary',
                  text: this.$t('立即评价'),
                  link:{
                    path:'/order_eval',
                    query:{
                      coid:coid,
                    }
                  }
                }
                this.buttons=[nurse_eval]
              }
            }
          })
      },
    }
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
